<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>禁止向对象中添加属性的API</title>
</head>
<body>
    <script>
        // 'use strict' 
        let hd = {name:"后盾人",age:18};

        // 禁止往某个对象中添加属性(严格模式下报错)
        // Object.preventExtensions(hd);
        // hd.size = 'big';
        // console.log(hd);


        // 禁止往某个对象中添加属性(严格模式下报错)
        Object.preventExtensions(hd);
        // 如果没有被禁止
        if(Object.isExtensible(hd)){
            hd.size = 'big';
        }
        console.log(hd);


    </script>
</body>
</html>